package CarRental;

import java.util.Scanner;

public class CarRentalTest {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        CarRental c = new CarRental("神州租车有限公司", "合肥坝上街166号",
                "0551--62166166");
        while (true) {
            System.out.println(">>>>>欢迎登陆神州租车有限公司>>>>>>");
            c.show();
               System.out.println("本公司现在有"+(c.getCount()-c.getTally())+"辆汽车可以出租");
            System.out.println("1.查看车辆情况；2.租车；3.还车；4.报废；5.采购新车；6.查看租车记录；" +
                    "7.查看总收入；0.退出");
            int a = input.nextInt();
            switch (a) {
                case 1:
                    System.out.println("***车辆情况***");
                    c.showCar();
                    break;
                case 2:
                    System.out.println("***租车***");
                    System.out.println("请确认您需要租用的汽车种类：\n1.轿车    2.客车");
                    c.rentshow(input.nextInt());
                    System.out.println("请输入您选择租用的车牌：");
                    String licensePlate = input.next();
                    Automobile au = c.rent(licensePlate);
                    if (au == null) {
                        System.out.println("租车失败！");
                        break;
                    }
                    System.out.println("请输入您的姓名：");
                    String name = input.next();
                    System.out.println("请输入您的性别：");
                    String sex = input.next();
                    System.out.println("请输入您的电话：");
                    String tel = input.next();
                    System.out.println("请输入您选择需要租用的天数：");
                    int day = input.nextInt();
                    double money = au.calculate(day);
                    Tenant te = new Tenant(name, sex, tel, licensePlate, day, money);
                    c.tenantInf(te);
                    System.out.println("请支付人名币" + money + "元。");
                    System.out.println("租车成功！");
                    break;
                case 3:
                    System.out.println("***还车***");
                    System.out.println("请确认您需要还的车牌：");
                    if (c.returnCar(input.next()))
                        System.out.println("还车成功！");
                    else System.out.println("还车失败！");
                    break;
                case 4:
                    System.out.println("***报废***");
                    System.out.println("请确认您需要报废的车牌：");
                    if (c.returnCar(input.next()))
                        System.out.println("报废成功！");
                    else System.out.println("报废失败！");
                    break;
                case 5:
                    System.out.println("***采购新车***");
                    int b = 0;
                    while (true) {
                        System.out.println("请选择新车类型：1.轿车；2.客车");
                        b = input.nextInt();
                        if (b == 1) {
                            Car newA = new Car();
                            System.out.println("请输入新车车牌：");
                            newA.setLicensePlate(input.next());
                            if (!c.add(newA)) {
                                System.out.println("添加新车失败，请重新添加！");
                                break;
                            }
                            System.out.println("请输入新车品牌：");
                            newA.setBrand(input.next());
                            System.out.println("请输入新车型号：");
                            newA.setModel(input.next());
                            System.out.println("请输入新车日租金：");
                            newA.setDailyRent(input.nextDouble());
                            System.out.println("添加新车成功！");
                            break;
                        } else if (b == 2) {
                            Coach newA = new Coach();
                            System.out.println("请输入新车车牌：");
                            newA.setLicensePlate(input.next());
                            if (!c.add(newA)) {
                                System.out.println("添加新车失败，请重新添加！");
                                break;
                            }
                            System.out.println("请输入新车品牌：");
                            newA.setBrand(input.next());
                            System.out.println("请输入新车座位数：");
                            newA.setSeat(input.nextInt());
                            System.out.println("请输入新车日租金：");
                            newA.setDailyRent(input.nextDouble());
                            System.out.println("添加新车成功！");
                            break;
                        }
                        System.out.println("输入错误，重新输入！");
                    }
                    break;
                case 6:
                    System.out.println("***查看租车记录***");
                    c.tenantShow();
                    break;
                case 7:
                    System.out.println("***查看总输入***");
                    double m = c.charterMoney();
                    System.out.println("总输入：人民币" + m + "元。");
                    break;
                case 0:
                    System.out.println("***退出***");
                    return;
            }
        }
    }
}
